import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import Sort from '../views/Sort.vue'
import Mine from '../views/Mine.vue'
import Cart from '../views/Cart.vue'
import Search from '../views/Search.vue'
import Error from '../views/Error.vue'
import Footer from '../components/Footer/Footer'
import Deatil from '../views/Detail.vue'
import Login from '../views/Login.vue'
import Register from '../views/register/Register.vue'
import Reg1 from '../views/register/Reg1.vue'
import Reg2 from '../views/register/Reg2.vue'
import Reg3 from '../views/register/Reg3.vue'
import Searchlist from '../components/Search/SearchList.vue'
import SearchMain from '../components/Search/SearchMain.vue'
import Nav from '../components/Search/NavBar.vue'
import bannerListimg from '../components/Detail/BannerList.vue'
import Updatepassword from '../views/Updatepassword'
import Order from '../views/Order'
import Address from "../views/Address.vue"
import EditAddress from "../components/Address/EditAddress"
import EditNewAddress from "../components/Address/EditNewAddress"
import Payend from "../views/Payend"


Vue.use(VueRouter)

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

const routes = [
  {
    path: "/",
    redirect: "/home"
  },
  {
    path: '/home',
    name: 'Home',
    components: {
      default: Home,
      Footer
    }
  },
  {
    path: '/sort',
    name: 'Sort',
    components: {
      default: Sort,
      Footer
    }
  },
  {
    path: '/cart',
    name: 'Cart',
    components: {
      default: Cart,
      Footer
    }
  },
  {
    path: '/mine',
    name: 'Mine',
    components: {
      default: Mine,
      Footer
    }
  },
  {
    path: "*",
    name: 'Error',
    component: Error
  },
  {
    path: "/Search",
    name: 'Search',
    component: Search,
    redirect: 'SearchMain',
    children: [
      {
        path: "/Searchlist/:keyword",
        name: 'Searchlist',
        components: {
          default: Searchlist,
          Nav
        }

      },
      {
        path: "/SearchMain",
        name: 'SearchMain',
        components:
        {
          default: SearchMain,
          Nav
        }
      },
    ]
  },
  {
    path: '/login',
    name: "Login",
    component: Login
  },
  {
    path: '/register',
    name: "Register",
    component: Register,
    redirect: 'register/one',
    children: [
      {
        path: "/register/one",
        name: "Reg1",
        component: Reg1
      },
      {
        path: "/register/two",
        name: "Reg2",
        component: Reg2
      },
      {
        path: "/register/three",
        name: "Reg3",
        component: Reg3
      }
    ]
  },
  {
    path: "/pro/detail/:proid",
    name: 'Deatil',
    component: Deatil,
   
  },
  {
    path: "/bannerListimg/:proid",
    name: "BannerList",
    component: bannerListimg
  },
  {
    path: "/updatepassword",
    name: "Updatepassword",
    component: Updatepassword
  },
  {
    path: "/order",
    name: "Order",
    component: Order
  },
  {
    path: "/address",
    name: "Address",
    component: Address
  },
  {
    path: "/editaddress/:addressid",
    name: "EditAddress",
    component: EditAddress
  },
  {
    path: "/editnewaddress",
    name: "EditNewAddress",
    component: EditNewAddress
  },
  {
    path: "/payend",
    name: "Payend",
    component: Payend
  },


]

const router = new VueRouter({
  routes
})

export default router
